#include <unistd.h>
#include "sys.h"
#include "Picture.h"
#include <mutex>

using namespace std;

static void pictureExitCallback(void);

static Picture *picture;
static mutex uiMutex;

int main(void)
{
    sys_init();
    lv_init(); // lvgl gui初始化
    lv_port_disp_init();
    lv_port_indev_init();
    lv_port_fs_init();

    picture = new Picture(pictureExitCallback, uiMutex);
    
    while (1)
    {
        uiMutex.lock();
        uint32_t ms = lv_task_handler();
        uiMutex.unlock();

        usleep(ms * 1000);
    }
}

/**
 *@brief picture退出回调函数
 */
static void pictureExitCallback(void)
{
    delete picture;
    sys_exit();

    exit(0);
}
